package com.M10.BE.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {

    private String TAG = "BaseFragment";

    View view = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.i(TAG,"onCreateView");
        if (view == null) {
            view = inflater.inflate(getLayoutId(), container, false);
            initView(view,inflater);
        }
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.removeView(view);
        }
        return view;
    }

    protected abstract void initView(View view,LayoutInflater inflater);

    protected abstract int getLayoutId();

}
